<?php
namespace common\sources\read\expiretimelog;

use common\models\craftsman\ExpireTimeLog;
use common\models\craftsman\BuyUser;

class ExpireTimeLogAccess  implements IExpireTimeLogAccess
{
    public function modifyExpireLog($buy_id, $data) {
        $query = ExpireTimeLog::find()
            ->select("buy_id,expire_time_befor,expire_time_now,create_time,description,imgUrl,operatorPhone,operatorName")
            ->where(['buy_id' => $buy_id]);
        if(!empty($data['begin_time'])){
            $query = $query->andWhere([
                '>',
                'create_time',
                $data['begin_time'],
            ]);
        }
        if(!empty($data['end_time'])){
            $query = $query->andWhere([
                '<',
                'create_time',
                $data['end_time'],
            ]);
        }
        $result = $query->asArray()
            ->all();
        return $result;
    }
}